--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[

    胡桃杀死蝴蝶会损失14点理智。

]]--
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

return function(inst)
    if not TheWorld.ismastersim then
        return
    end

    local butterfly_prefab = {
        ["butterfly"] = true,
        ["moonbutterfly"] = true,
    }

    inst:ListenForEvent("killed",function(inst,_table)
        local target = _table and _table.victim
        if target and butterfly_prefab[target.prefab] then
            local kill_num = 1
            if target.components.stackable then
                kill_num = target.components.stackable:StackSize()
            end
            for i = 1, kill_num do
                inst.components.sanity:DoDelta(-14)
            end
            inst.components.hutao_com_dialogue:Say("butterfly_killed")
        end
    end)
end